using System.Collections.Generic;
using UnityEngine;

namespace CinemaDirector
{
	[CutsceneItem("Utility", "Mass Disabler")]
	public class MassDisabler : CinemaGlobalAction
	{
		public List<GameObject> GameObjects = new List<GameObject>();

		public List<string> Tags = new List<string>();

		private List<GameObject> tagsCache = new List<GameObject>();

		public override void Trigger()
		{
			tagsCache.Clear();
			foreach (string tag in Tags)
			{
				GameObject[] array = GameObject.FindGameObjectsWithTag(tag);
				GameObject[] array2 = array;
				foreach (GameObject item in array2)
				{
					tagsCache.Add(item);
				}
			}
			setActive(false);
		}

		public override void End()
		{
			setActive(true);
		}

		private void setActive(bool enabled)
		{
			foreach (GameObject gameObject in GameObjects)
			{
				gameObject.SetActive(enabled);
			}
			foreach (GameObject item in tagsCache)
			{
				item.SetActive(enabled);
			}
		}
	}
}
